class BaseUtils {
  /**
   * 防抖
   * @param fn 
   * @param delay 
   */
  public static deBounce<T>(fn: T, delay: number = 30): () => void {
    let timer: NodeJS.Timeout
    return function(): void {
      const args: any[] = Array.prototype.map.call(arguments, val => val);
      if (timer) {
        clearTimeout(timer);
      }
      timer = setTimeout(() => {
        typeof fn === 'function' && fn.apply(null, args);
        clearTimeout(timer);
      }, delay);
    };
  }
}

export default BaseUtils
